package org.crumbleworks.crumbcrane.entity;

import static org.junit.Assert.*;

import org.crumbleworks.crumbcrane.crate.explosive.TNTCrate;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class Entity2DTest {
    Entity2D entity1, entity2;

    @Before
    public void setUp() throws Exception {
        entity1 = new TNTCrate(1, 1, 20, 20, 1, 1, 1, 20, 10, 5);
        entity2 = new TNTCrate(10, 10, 5, 5, 0, 1, 0, 50, 5, 30);
    }
    
    @After
    public void tearDown() throws Exception {
        entity1 = null;
        entity2 = null;
    }

    @Test
    public void testGetLocation() throws Exception {
        double[] expected1 = {1, 1};
        assertArrayEquals(expected1, entity1.getLocation(), 0);
        
        double[] expected2 = {10, 10};
        assertArrayEquals(expected2, entity2.getLocation(), 0);
    }

    @Test
    public void testGetSize() throws Exception {
        double[] expected1 = {20, 20};
        assertArrayEquals(expected1, entity1.getSize(), 0);
        
        double[] expected2 = {5, 5};
        assertArrayEquals(expected2, entity2.getSize(), 0);
    }

    @Test
    public void testGetColor() throws Exception {
        double[] expected1 = {1, 1, 1};
        assertArrayEquals(expected1, entity1.getColor(), 0);
        
        double[] expected2 = {0, 1, 0};
        assertArrayEquals(expected2, entity2.getColor(), 0);
    }

    @Test
    public void testInBounds() throws Exception {
        assertTrue(entity1.inBounds(2, 2));
        assertFalse(entity1.inBounds(22, 22));
        
        assertTrue(entity1.inBounds(entity2));
    }
}
